package com.itheima.dao;

import com.itheima.domain.Account;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;
public interface AccountAnnotationDao {


    @Select("select * from account")
    @Results(id = "accountUserMap", value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "uid", property = "uid"),
            @Result(column = "money", property = "money"),
            @Result(column = "uid", property = "user", one = @One(select = "com.itheima.dao.UserAnnotationDao.findById", fetchType = FetchType.EAGER)
            )
    })
    List<Account> findAll();


    @Select("select * from account where uid = #{uid}")
    List<Account> findByUid(int uid);
}
